package com.dinim.matrix.twodimensional;

import com.dinim.matrix.Matrix;

public class Matrix3x3 extends Matrix {

	public Matrix3x3() {
		super(3, 3);
	}

	public void setLine(double n0, double n1, double n2, int line){
		double[] values = new double[]{n0, n1, n2};
		super.setLine(values, line);
	}

	public void setRow(double n0, double n1, double n2, int row){
		double[] values = new double[]{n0, n1, n2};
		super.setLine(values, row);
	}

	/******************************
	 * S T A T I C   M E T H O D S
	 ******************************/
	public static Matrix3x3 generateScalingMatrixXY(double x, double y){	
		Matrix3x3 scalingMatrix = Matrix3x3.generateStandardMatrix();
		scalingMatrix.set(0, 0, x);
		scalingMatrix.set(1, 1, y);
		return scalingMatrix;
	}
	
	public static Matrix3x3 generateScalingMatrixX(double x){	
		Matrix3x3 scalingMatrix = Matrix3x3.generateStandardMatrix();
		scalingMatrix.set(0, 0, x);
		return scalingMatrix;
	}
	
	public static Matrix3x3 generateScalingMatrixY(double y){	
		Matrix3x3 scalingMatrix = Matrix3x3.generateStandardMatrix();
		scalingMatrix.set(1, 1, y);
		return scalingMatrix;
	}
	/*
	 * 
	 */
	public static Matrix3x3 generateTranslationMatrixXY(double x, double y){		
		Matrix3x3 translationMatrix = Matrix3x3.generateStandardMatrix();
		translationMatrix.set(0, 2, x);
		translationMatrix.set(1, 2, y);
		return translationMatrix;
	}
	
	public static Matrix3x3 generateTranslationMatrixX(double x){		
		Matrix3x3 translationMatrix = Matrix3x3.generateStandardMatrix();		 
		translationMatrix.set(0, 2, x);
		return translationMatrix;
	}

	public static Matrix3x3 generateTranslationMatrixY(double y){
		Matrix3x3 translationMatrix = Matrix3x3.generateStandardMatrix();		 
		translationMatrix.set(1, 2, y);
		return translationMatrix;
	}
	/*
	 * 
	 */
	public static Matrix3x3 generateRotationMatrix(double angle){	
		Matrix3x3 rotationMatrix = Matrix3x3.generateStandardMatrix();
		rotationMatrix.set(0, 0, Math.cos(Math.toRadians(angle)));
		rotationMatrix.set(1, 0, Math.sin(Math.toRadians(angle)));
		rotationMatrix.set(0, 1, -Math.sin(Math.toRadians(angle)));
		rotationMatrix.set(1, 1, Math.cos(Math.toRadians(angle)));
		return rotationMatrix;
	}
	/*
	 * 
	 */
	public static Matrix3x3 generateStandardMatrix(){
		Matrix3x3 standardMatrix = new Matrix3x3();
		int i = 0;
		standardMatrix.setLine(1, 0, 0, i++);
		standardMatrix.setLine(0, 1, 0, i++);
		standardMatrix.setLine(0, 0, 1, i++);		
		return standardMatrix;
	}
}
